package com.example.cr.insect.controller.admin;

import com.example.cr.common.response.PageResponse;
import com.example.cr.common.response.R;
import com.example.cr.insect.request.PreventionLogListRequest;
import com.example.cr.insect.response.PreventionLogResponse;
import com.example.cr.insect.service.PreventionLogService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.cr.insect.request.PreventionLogRequest;
import java.util.List;

@RestController
@RequestMapping("admin/prevention-log")
public class PreventionLogAdminController {
    @Autowired
    PreventionLogService preventionLogService;

    @GetMapping("list")
    public R<PageResponse<PreventionLogResponse>> list(@Valid PreventionLogListRequest request) {
        PageResponse<PreventionLogResponse> list = preventionLogService.list(request);
        return R.ok(list);
    }
    @PostMapping("save")
    public R<Object> save(@Valid @RequestBody PreventionLogRequest request) {
        preventionLogService.save(request);
        return R.ok();
    }

    @DeleteMapping("delete")
    public R<Integer> delete(@RequestBody List<Long> ids) {
        int result = preventionLogService.deleteBatch(ids);
        return R.ok(result);
    }
}
